package distributedbank.responses;

import java.io.IOException;
import java.text.DecimalFormat;
import java.text.NumberFormat;

import distributedbank.client.ClientUI;

/**
 * A BalanceResponse is sent by a BankBranch after receiving a Request message
 * from a GUI process. The BalanceResponse reports the current balance of the
 * pertinent bank account.
 */
public class BalanceResponse extends Response
{
	private static final long serialVersionUID = 6267703026226376486L;
	public int balance;
	private static final NumberFormat nf = new DecimalFormat(
      		"###,###,###,###,###,##0.00" );

	public BalanceResponse( int balance ) {
		this.balance = balance;
	}
	public void runResponse( ClientUI client ) throws IOException {
		client.readMessage( "Success! The current balance is $"
				+ nf.format( balance / 100.0 ) + "\n" );
	}
}